package com.aptemo.webetek.server.handlers;

import com.aptemo.webetek.client.commands.Action;
import com.aptemo.webetek.client.commands.impl.GetTeamsPagingAction;
import com.aptemo.webetek.client.exceptions.BackendException;
import com.aptemo.webetek.server.datastore.DataStoreAPI;
import com.aptemo.webetek.shared.PagingResult;
import com.aptemo.webetek.shared.TeamBean;

public class TeamsPagingHandler
		extends ActionHandler<GetTeamsPagingAction, PagingResult<TeamBean>>
{

	public TeamsPagingHandler(DataStoreAPI service)
	{
		super(service);
	}

	public Class<? extends Action<?>> getActionType()
	{
		return GetTeamsPagingAction.class;
	}

	@Override
	public PagingResult<TeamBean> invoke(GetTeamsPagingAction action) throws BackendException
	{
		PagingResult<TeamBean> res = dataService.getTeams(action.getNameFilter(), action.isPublic(), action.getOrder(), action.getCursor(), action
				.getPageSize());
		return res;
	}

}
